Skip to content

Improve hybrid AI evaluation of costs and delayed effects - #11493

Open
Madwand99 wants to merge 1 commit into
Card-Forge:masterfrom
Madwand99:ImproveOnePlaySafetyChecker
Open

Improve hybrid AI evaluation of costs and delayed effects#11493
Madwand99 wants to merge 1 commit into
Card-Forge:masterfrom
Madwand99:ImproveOnePlaySafetyChecker

Conversation

@Madwand99

Copy link
Copy Markdown
Contributor

Summary

This improves the depth-zero safety check used by Hybrid AI when a play has explicit costs or mandatory delayed consequences.

Previously, the checker compared the final result directly against the original board state. This could reject reasonable plays because discarded, sacrificed, or temporarily removed cards appeared to be permanent losses. It also could not evaluate next-turn delayed draws because those triggers were not exposed until cleanup.

The checker now:

  • Uses the post-cost game state as the comparison baseline, leaving cost approval to the existing AI heuristics.
  • Resolves the proposed play and its resulting stack before evaluating it.
  • Evaluates newly created mandatory delayed returns to hand or battlefield.
  • Evaluates concrete next-turn delayed draws, allowing their benefits and associated draw-punisher triggers to affect the result.
  • Ignores optional and UnlessCost delayed effects rather than inventing a choice for the AI.
  • Continues to treat land plays separately so enters-the-battlefield drawbacks are compared against the pre-play position.

TriggerHandler now retains pending NextTurn triggers in a snapshot-accessible collection. Their normal game timing is unchanged: they still become active at cleanup exactly as before.

Regression coverage includes:

  • Explicit discard costs such as Phantasmagorian.
  • Nine-Lives Familiar returning from the graveyard.
  • Ignorant Bliss and Memory Jar restoring temporarily removed hands.
  • Lat-Nam's Legacy receiving its next-turn cards.
  • Urza's Bauble not hiding immediate lethal Disciple of the Vault damage.
  • Urza's Bauble being rejected when its delayed draw is lethal through Nekusar.

Thanks to Codex for help with code and tests!

@tool4ever

Copy link
Copy Markdown
Contributor

Getting a bit too hacky for my taste again 😩
might be a while before I have time to come up with more detailed feedback, some other PR have higher priority for now

@Madwand99

Copy link
Copy Markdown
Contributor Author

Getting a bit too hacky for my taste again 😩

The main "hack" here is that I evaluate delayed effects (such as the delayed draw from Lat-Nam's Legacy) as if it is happening immediately. There might be a better way to approximate this. Open to ideas! Or we could leave this approximation out and just be content with the safety checker just denying certain cards.

@tool4ever tool4ever mentioned this pull request Aug 5, 2026
@Madwand99
Madwand99 force-pushed the ImproveOnePlaySafetyChecker branch from de0b600 to df4c24a Compare August 7, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants